Lines 0--5 are the various necessary import statements for the R-GMA
java classes.

Lines 14--15 create a the primary producer which supports continuous
queries, with memory based storage. The user can specify that the
producer supports history and/or latest queries.

Lines 16--22 define the predicate and a pair of retention periods (60
minutes in each case) and then declare the intention of publishing to
a table called \texttt{default.userTable}. A producer is able to
publish to more than one table.

Lines 23--26 build an SQL insert statement and then call
the \texttt{insert} method of the primary producer with that SQL
statement as an argument.

Line 27 closes the primary producer.

Lines 28--31 report any R-GMA exceptions that may occur.

\subsubsection{Resilient Primary Producer Example}

This example illustrates how to write a resilient producer according
to the recommendations in section \ref{sec:advice}. The primary
producer publishes information periodically every 30 seconds. If there
is a temporary problem it retries after one minute. If there is a
permanent problem then the program exits.

\input{ResilientPrimaryProducer-java}

Lines 0--6 are the various necessary import statements for the R-GMA
java classes.

Lines 15--18 set up the history and latest retention periods.

Line 19 set up initial state for the producer.

Lines 20--29 create a new primary producer. If there is an
RGMATemporaryException then sleep for 60 seconds before retrying to
recreate the producer.

Line 30 set up the producer predicate.

Line 31 set up initial state for the table.

Lines 32--42 declare the \texttt{default.userTable}. If there is an
RGMATemporaryException then sleep for 60 seconds before trying to
re-declare the table.

Line 43 initialises the data value that is going to be inserted into
each tuple.

Lines 44--58 loops forever - each iteration will insert a new
tuple. In our example, tuples contain the userId and the current value
of the \texttt{data} variable that gets incremented on each successful
iteration of the loop. For the purpose of this example a delay of 30
seconds has been introduced between each insert. If there is an
RGMATemporaryException then sleep for 60 seconds before retrying to
insert the tuple.

Lines 59--62 report an RGMAPermanentException. As this is considered
to be a permanent problem there is no point retrying the operation.
